package com.ruoyi.equ.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.equ.domain.EquCombination;
import com.ruoyi.equ.service.IEquCombinationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备信息关联Controller
 * 
 * @author ruoyi
 * @date 2020-10-22
 */
@RestController
@RequestMapping("/equ/combination")
public class EquCombinationController extends BaseController
{
    @Autowired
    private IEquCombinationService equCombinationService;

    /**
     * 查询设备信息关联列表
     */
    //@PreAuthorize("@ss.hasPermi('system:combination:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquCombination equCombination)
    {
        startPage();
        List<EquCombination> list = equCombinationService.selectEquCombinationList(equCombination);
        return getDataTable(list);
    }

    /**
     * 导出设备信息关联列表
     */
    //@PreAuthorize("@ss.hasPermi('system:combination:export')")
    @Log(title = "设备信息关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EquCombination equCombination)
    {
        List<EquCombination> list = equCombinationService.selectEquCombinationList(equCombination);
        ExcelUtil<EquCombination> util = new ExcelUtil<EquCombination>(EquCombination.class);
        return util.exportExcel(list, "combination");
    }

    /**
     * 获取设备信息关联详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:combination:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo( @PathVariable("id") String id)
    {
        return AjaxResult.success(equCombinationService.selectEquCombinationById(id));
    }

    /**
     * 新增设备信息关联
     */
    //@PreAuthorize("@ss.hasPermi('system:combination:add')")
    @Log(title = "设备信息关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquCombination equCombination)
    {
        return toAjax(equCombinationService.insertEquCombination(equCombination));
    }

    /**
     * 修改设备信息关联
     */
    //@PreAuthorize("@ss.hasPermi('system:combination:edit')")
    @Log(title = "设备信息关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquCombination equCombination)
    {
        return toAjax(equCombinationService.updateEquCombination(equCombination));
    }

    /**
     * 删除设备信息关联
     */
    //@PreAuthorize("@ss.hasPermi('system:combination:remove')")
    @Log(title = "设备信息关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(equCombinationService.deleteEquCombinationByIds(ids));
    }
}
